import request from '@/config/axios'

// 对话 VO
export interface MessageVO {
  messageId: number // 唯一自增id
  sessionId: number // 会话id
  senderType: number // 消息发送者类型, 1: 用户，2: AI
  content: string // 消息内容
  contentType: number // 消息类型, 1: 文本/音频, 2: 图片, 3: 视频
  audioPath: string // 音频地址
  responseTimeMs: number // AI生成回复的时间 (毫秒)
  extension: string // 扩展
}

// 对话 API
export const MessageApi = {
  // 查询对话分页
  getMessagePage: async (params: any) => {
    return await request.get({ url: `/lm/message/page`, params })
  },

  // 查询对话详情
  getMessage: async (id: number) => {
    return await request.get({ url: `/lm/message/get?id=` + id })
  },

  // 新增对话
  createMessage: async (data: MessageVO) => {
    return await request.post({ url: `/lm/message/create`, data })
  },

  // 修改对话
  updateMessage: async (data: MessageVO) => {
    return await request.put({ url: `/lm/message/update`, data })
  },

  // 删除对话
  deleteMessage: async (id: number) => {
    return await request.delete({ url: `/lm/message/delete?id=` + id })
  },

  // 导出对话 Excel
  exportMessage: async (params) => {
    return await request.download({ url: `/lm/message/export-excel`, params })
  }
}